package hsb.ruoyi.admin.web.controller.monitor;

import hsb.ruoyi.common.annotation.Log;
import hsb.ruoyi.common.core.controller.BaseController;
import hsb.ruoyi.common.core.domain.AjaxResult;
import hsb.ruoyi.common.core.page.TableDataInfo;
import hsb.ruoyi.common.enums.BusinessType;
import hsb.ruoyi.system.domain.SysLogininfor;
import hsb.ruoyi.system.service.ISysLogininforService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.List;

/**
 * 系统访问记录
 * 
 * @author ruoyi
 */
@Produces(MediaType.APPLICATION_JSON)
@Path("/monitor/logininfor")
public class SysLogininforController extends BaseController
{
    @Autowired
    private ISysLogininforService logininforService;

    //@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
    @GET
    @Path("/list")
    public TableDataInfo list(@BeanParam SysLogininfor logininfor)
    {
        startPage();
        List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
        return getDataTable(list);
    }

//    //@Log(title = "登录日志", businessType = BusinessType.EXPORT)
//    //@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
//    @POST @Path("/export")
//    public void export(HttpServletResponse response, SysLogininfor logininfor)
//    {
//        List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
//        ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
//        util.exportExcel(response, list, "登录日志");
//    }

    //@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
    @Log(title = "登录日志", businessType = BusinessType.DELETE)
    @DELETE
    @Path("/{infoIds}")
    public AjaxResult remove(@PathParam("infoIds") Long[] infoIds)
    {
        return toAjax(logininforService.deleteLogininforByIds(infoIds));
    }

    //@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
    @Log(title = "登录日志", businessType = BusinessType.CLEAN)
    @DELETE @Path("/clean")
    public AjaxResult clean()
    {
        logininforService.cleanLogininfor();
        return AjaxResult.success();
    }
}
